package com.budwk.app.sqfwV2.service.shawenTown;

import com.alibaba.fastjson.JSONObject;
import com.budwk.app.sqfw.models.Sqfw_formSummary_new;
import com.budwk.app.sqfw.vo.GenerateExcelUrlVO;
import com.budwk.app.sqfwDoc.bo.ExcelCreateConfig;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseExcelParamDTO;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.ExcelGeneratorConfig;
import com.budwk.app.sqfwDoc.codeGenerator.impl.SqfwTemplateExcelCommonService;
import com.budwk.app.sqfwDoc.codeGenerator.pdfGenerate.AbstractCustomerPdfCreateField;
import com.budwk.app.sqfwV2.component.ShawenTownComponent;
import com.budwk.app.sqfwV2.dto.shawenTown.ShawenTownSafetyPdfDTO;
import lombok.extern.slf4j.Slf4j;
import org.nutz.ioc.loader.annotation.IocBean;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author 东方祥云低代码1.1
 * @since 2024-03-11
 *
 * 沙文消防安全排查 ShawenTownSafety
 */
@IocBean
@Slf4j
public class ShawenTownSafetyExcelService extends SqfwTemplateExcelCommonService {

    @Override
    public List<GenerateExcelUrlVO> generateExcel(List<ExcelCreateConfig> excelConfigList, String userId, List<String> sqfwIdList) {
        return super.generateExcel(excelConfigList, userId, sqfwIdList);
    }

    public List<GenerateExcelUrlVO> downExcelLedger(List<ExcelCreateConfig> excelConfigList, String userId, List<String> sqfwIdList, List<Sqfw_formSummary_new> list) {
        return super.generateExcelCommon(excelConfigList, userId, sqfwIdList, list);
    }

    @Override
    protected void customerPopularBaseExcelParam(BaseExcelParamDTO baseExcelParam, String userId, List<String> sqfwIdList) {

    }

    @Override
    protected void customerPopularBaseExcelParamForAdmin(BaseExcelParamDTO baseExcelParam, String userId, List<String> formSummaryNewIdList) {

    }

    @Override
    protected List<ExcelGeneratorConfig> getExcelCodeGeneratorConfig(List<ExcelCreateConfig> excelConfigList, BaseExcelParamDTO baseExcelParam) {
        log.info("shawen excel getExcelCodeGeneratorConfig: {}", JSONObject.toJSONString(excelConfigList));
        if (excelConfigList.size() == 0) {
            return Collections.emptyList();
        }
        // 查询大营路EXCEL台账合集字典数据
        List<ExcelGeneratorConfig> list = new ArrayList<>();
        for (ExcelCreateConfig config : excelConfigList) {
            ExcelGeneratorConfig generatorConfig = new ExcelGeneratorConfig();
            BaseTemplateExcelGenerator service = ShawenTownComponent.getService(config.getFileIdentity());
            generatorConfig.setGenerator(service);
            generatorConfig.setExcelCreateConfig(config);
            list.add(generatorConfig);
        }
        return list;
    }

    @Override
    protected AbstractCustomerPdfCreateField parseParamData(String paramDataStr) {
        return JSONObject.parseObject(paramDataStr, ShawenTownSafetyPdfDTO.class);
    }

    @Override
    protected String getSqfwFormSummaryType() {
        return ShawenTownComponent.FILL_TYPE;
    }
}
